﻿requirejs.config({
    baseUrl: ".",
    paths: {
    	zepto:"javascripts/zepto.min",
    	dingtalk:"javascripts/dingtalk",
        vue: "components/vue/vue.min",
        axios: "components/axios/axios.min",
        common: "resources/js/common"
    }
});

require(["zepto","dingtalk","vue", "axios", "common"], function (zepto,dingtalk,Vue, axios, common) {
    var vm = new Vue({
        el: "#view",
        data: {
            keyword: "",
            isQuery: false,
            result: [],
            newKnowledge: [],
            warn: []
        },
        mounted: function () {
            var self = this;

            axios.get("knowledge/top")
                .then(function (response) {
                    self.warn = response.data.warn;
                    self.newKnowledge = response.data.new;
                });
        },
        methods: {
            query: function () {
                var self = this;

                isQuery = !common.isEmpty(this.keyword);
                if (isQuery)
                    axios.get("knowledge/query?keyword=" + this.keyword)
                        .then(function (response) {
                            self.isQuery = true;
                            self.result = response.data;
                        });
            },
            gotoList: function (kngKnowledgeCategoryName) {
                window.location.href = "knowledgeList.html?kngKnowledgeCategoryName=" + kngKnowledgeCategoryName;
            },
            gotoPublish: function (id) {
                window.location.href = "knowledgePublish.html";
            },
            gotoDetail: function (id) {
                window.location.href = "knowledgeDetail.html?id=" + id;
            }
        }
    });
});